{template 'common/header-gw'}
<ol class="breadcrumb">
	<li><a href="./?refresh"><i class="fa fa-home"></i></a></li>
	<li><a href="{url 'system/welcome'}">用户管理</a></li>
	<li><a href="{url 'user/group'}">用户组</a></li>
	<li class="active">{if $do == 'display'}用户组列表{elseif $do == 'post'}{if $id}编辑{else}添加{/if}用户组{/if}</li>
</ol>
<ul class="nav nav-tabs">
	<li {if $do == 'display'}class="active"{/if}><a href="{php echo url('user/group/display');}">用户组列表</a></li>
	<li {if $do == 'post' && empty($id)}class="active"{/if}><a href="{php echo url('user/group/post');}">添加用户组</a></li>
	{if !empty($id)}
	<li {if $do == 'post' && !empty($id)}class="active"{/if}><a href="{php echo url('user/group/post', array('id' => $id));}">编辑用户组</a></li>
	{/if}
</ul>
{if $do == 'post'}

<div class="clearfix">
	<form action="" method="post"  class="form-horizontal" role="form" enctype="multipart/form-data" onsubmit="return formcheck(this)">
		<h5 class="page-header">用户组管理</h5>
		<input type="hidden" name="id" value="{$id}" />
		<input type="hidden" name="templateid" value="{$template['id']}">
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">名称</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" name="name" id="name" value="{$group['name']}" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">公众号数量</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" name="maxaccount" value="{$group['maxaccount']}" />
				<span class="help-block">限制公众号的数量，为0则不允许添加。</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">子公众号数量</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" name="maxsubaccount" value="{$group['maxsubaccount']}" />
				<span class="help-block">限制子公众号的数量，为0则不允许添加。</span>
			</div>
		</div>
		
		<h5 class="page-header">设置可使用的公众号组</h5>
		<div class="panel panel-default">
		<div class="panel-body table-responsive">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:50px;" class="row-first">选择</th>
					<th style="min-width:100px;">公众服务套餐</th>
					<th>模块权限</th>
					<th>模板权限</th>
					<th></th>
				</tr>
			</thead>
			<tbody>
				{loop $packages $item}
				<tr>
					<td class="row-first"><input class="modules" type="checkbox" value="{$item['id']}" name="package[]" {if !empty($group['package']) && in_array($item['id'], $group['package'])}checked{/if} /></td>
					<td>{$item['name']}</td>
					<td style="line-height:25px;">
						<span class="label label-success">系统模块</span>
						{loop $item['modules'] $module}
						<span class="label label-info">{$module['title']}</span>
						{/loop}
					</td>
					<td style="line-height:25px;">
						<span class="label label-success">微站默认模板</span>
						{loop $item['templates'] $template}
						<span class="label label-info">{$template['title']}</span>
						{/loop}
					</td>
					<td></td>
				</tr>
				{/loop}
			</tbody>
		</table>
		</div>
		</div>
		<div class="form-group">
			<div class="col-sm-offset-2 col-md-offset-2 col-lg-offset-1 col-xs-12 col-sm-10 col-md-10 col-lg-11">
				<input name="token" type="hidden" value="{$_W['token']}" />
				<input type="submit" class="btn btn-primary span3" name="submit" value="提交" />
			</div>
		</div>
	</form>
</div>

{elseif $do == 'display'}

<form action="" method="post">
<div class="panel panel-default">
	<div class="panel-body table-responsive">
	<table class="table table-hover">
		<thead class="navbar-inner">
			<tr>
				<th style="width:30px;">删？</th>
				<th style="width:150px;">名称</th>
				<th>公众号数量</th>
				<th>子公众号数量</th>
				<th style="min-width:60px;">操作</th>
			</tr>
		</thead>
		<tbody>
			{loop $list $item}
			<tr>
				<td><input type="checkbox" name="delete[]" value="{$item['id']}" /></td>
				<td>{$item['name']}</td>
				<td>{if empty($item['maxaccount'])}不限{else}{$item['maxaccount']}{/if}</td>
				<td>{if empty($item['maxsubaccount'])}无权限{else}{$item['maxsubaccount']}{/if}</td>
				<td><span><a href="{php echo url('user/group/post', array('id' => $item['id']))}">编辑</a></span></td>
			</tr>
			{/loop}
		</tbody>
		<tr>
			<th></th>
			<td>
				<input name="token" type="hidden" value="{$_W['token']}" />
				<input type="submit" class="btn btn-primary span3" name="submit" value="提交" />
			</td>
		</tr>
	</table>
	</div>
</div>
</form>
{/if}
{template 'common/footer-gw'}